package com.webServices;

import com.databaseManager.DatabaseFunc;
import com.databaseManager.Doctor;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class UpdateRecord extends HttpServlet {
    private Doctor user;
    private DatabaseFunc df;
    public void init() throws ServletException
    {
        // 执行必需的初始化
        user = null;
        df = new DatabaseFunc();
    }

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
            throws ServletException, IOException
    {
        // 设置响应内容类型
        response.setContentType("text/html;charset=utf-8");
        System.out.println(request.getRequestURL());

        // 实际的逻辑是在这里
        if(true)
        {
            PrintWriter out = response.getWriter();
            out.print("<script>alert(\"病历新建成功，已写入数据库！\")</script>");
        }
        else
        {
            PrintWriter out = response.getWriter();
            out.print("<script>alert(\"病历新建失败！\")</script>");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }


    public void destroy()
    {
        // 什么也不做
    }
}
